package com.zhkj.txg.module.home.popup

import android.content.Context
import android.view.Gravity
import android.view.View
import android.view.animation.Animation
import com.zhkj.txg.R
import razerdp.basepopup.BasePopupWindow

class SelectedGenderDialog(context: Context, val onSelected: (man: Boolean) -> Unit) :
    BasePopupWindow(context) {

    init {
        popupGravity = Gravity.BOTTOM
    }

    override fun onCreateContentView(): View = createPopupById(R.layout.popup_merchant_gender)

    override fun onCreateShowAnimation(width: Int, height: Int): Animation =
        getTranslateVerticalAnimation(1f, 0f, 300)

    override fun onCreateDismissAnimation(): Animation = getTranslateVerticalAnimation(0f, 1f, 300)

    override fun onViewCreated(contentView: View?) {
        contentView?.findViewById<View>(R.id.tvMan)?.setOnClickListener {
            onSelected(true)
            dismiss()
        }
        contentView?.findViewById<View>(R.id.tvWomen)?.setOnClickListener {
            onSelected(false)
            dismiss()
        }
        contentView?.findViewById<View>(R.id.tvConfirm)?.setOnClickListener { dismiss() }
    }
}